package com.glsc.ngateway.common.base.domain.mysql.gateway.platform;

import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import javax.persistence.*;
import java.io.Serializable;
import java.util.Objects;


/**
 * @author tangyf
 * @date 2021/12/1
 * 流程节点可编辑字段表
 */
@Data
@Entity
@IdClass(value = ProcessEditConfig.PK.class)
@org.hibernate.annotations.Table(appliesTo = "t_gw_process_edit_config", comment = "流程节点可编辑字段表")
@Table(name = "t_gw_process_edit_config")
public class ProcessEditConfig implements Serializable {

    private static final long serialVersionUID = -7801251597767497023L;

    @ApiModelProperty(value = "流程类型标识")
    @Id
    @Column(name = "process_type", columnDefinition = "varchar(50) COMMENT '流程类型标识'")
    private String processType;

    @ApiModelProperty(value = "流程节点标识，对应flowable的taskDefinitionKey")
    @Id
    @Column(name = "node_type", columnDefinition = "varchar(50) COMMENT '流程节点标识，对应flowable的taskDefinitionKey'")
    private String nodeType;

    @ApiModelProperty(value = "流程节点标识中文名称")
    @Id
    @Column(name = "node_name", columnDefinition = "varchar(50) COMMENT '流程节点中文名称'")
    private String nodeName;

    @ApiModelProperty(value = "配置是否生效，Y/N")
    @Column(name = "activated", columnDefinition = "varchar(10) COMMENT '配置是否生效，Y/N'")
    private String activated;

    @ApiModelProperty(value = "节点可以编辑字段，默认为必填字段，多个英文逗号分割")
    @Column(name = "edit_fields", columnDefinition = "text COMMENT '节点可以编辑字段列表，多个英文逗号分割'")
    private String editFields;

    @ApiModelProperty(value = "节点可以选填编辑字段，多个英文逗号分割")
    @Column(name = "optional_edit_fields", columnDefinition = "text COMMENT '节点可以选填编辑字段，多个英文逗号分割'")
    private String optionalEditFields;

    @ApiModelProperty(value = "节点可以退回至上一步，yesno字典 Y/N")
    @Column(name = "node_can_rollback", columnDefinition = "varchar(10) COMMENT '节点可以退回至上一步，yesno字典 Y/N'")
    private String nodeCanRollback;

    @ApiModelProperty(value = "节点任务描述，节点操作说明")
    @Column(name = "task_description", columnDefinition = "varchar(500) COMMENT '节点任务描述'")
    private String taskDescription;

    public static class PK implements Serializable {

        private String processType;
        private String nodeType;

        public PK() {
        }

        public String getProcessType() {
            return processType;
        }

        public void setProcessType(String processType) {
            this.processType = processType;
        }

        public String getNodeType() {
            return nodeType;
        }

        public void setNodeType(String nodeType) {
            this.nodeType = nodeType;
        }

        @Override
        public boolean equals(Object o) {
            if (this == o) return true;
            if (o == null || getClass() != o.getClass()) return false;
            PK pk = (PK) o;
            return Objects.equals(processType, pk.processType) && Objects.equals(nodeType, pk.nodeType);
        }

        @Override
        public int hashCode() {
            return Objects.hash(processType, nodeType);
        }
    }
}
